package com.itheima.web.exception;

import com.itheima.domain.ResultInfo;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@ControllerAdvice
public class ControllerExceptionAdvice {
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public ResultInfo error(Exception e, HttpServletRequest request){
        e.printStackTrace();
        return new ResultInfo(false, "服务器错误", e);
    }
}
